package jdk8.function.interfaceX;

/**
 * 使用Lambda优化日志
 * Lambda的延迟加载特性
 **/
public class Demo02LambdaLog {
    public static void showLog(int level, Demo02MessageBuilder msg) {
        if (level == 1) {
            System.out.println(msg.msg());
        }
    }

    public static void main(String[] args) {
        String msg1 = " Hello ";
        String msg2 = " World ";
        String msg3 = " Java ";

        // 使用Lambda仅仅是把参数传递到showLog()中, 只有民族了条件才会拼接字符串并打印
        showLog(1, () -> {
            return msg1 + msg2 + msg3;
        });

    }
}
